Function.prototype.call2 = function (context2, ...args) {
  let context = context2 || window;
  // 这个this 是调用者
  context.fn = this;
  // 这里执行了 一下这个代码，返回
  // 下面这两种方式好像是没有什么区别的
  let result = eval("context.fn(...args)");
  // let result = context.fn(...args);
  // console.log(result);
  delete context.fn;
  return result;
};

let obj1 = {
  name: "jack",
  sex: "男",
  getName: function (msg) {
    return msg + this.name + this.sex;
  },
};
let b = {
  name: "lily",
};

// console.log(obj1.getName("hello"));
console.log(obj1.getName.call2(b, "hi"));
// console.log(obj1.getName.apply(b, ["hi~"]));
// let name1 = obj1.getName.bind(b);
// console.log(name1("hi~"));
